#define  _CRT_SECURE_NO_WARNINGS 1
#include<string.h>
#include <stdio.h>
#include<stdlib.h>

int* productExceptSelf(int* nums, int numsSize) {
    int* retarr;
    int i, j;
    int sum = 1;
    int left[4];
    int right[4];

    retarr = (int*)malloc(sizeof(int) * numsSize);
    memset(retarr, 0, sizeof(int) * numsSize);
    memset(left, 0, sizeof(int) * numsSize);
    memset(right, 0, sizeof(int) * numsSize);
    left[0] = 1;
    for (i = 0; i < numsSize - 1; i++) {
        left[i + 1] = left[i] * nums[i];
    }

    right[numsSize - 1] = 1;
    for (i = numsSize - 1; i > 0; i--) {
        right[i - 1] = right[i] * nums[i];
    }

    for (i = 0; i < numsSize; i++) {
        retarr[i] = left[i] * right[i];
    }
    return retarr;
}
int main() {
    int x[] = { 1,2,3,4 };
    int sz = sizeof(x) / sizeof(x[0]);
    productExceptSelf(x, sz);
    return 0;
}